Skip to content

Skip set_mempolicy for phantom NUMA nodes#296

Open
nileshnegi wants to merge 1 commit into
candidatefrom
users/nileshnegi/fix/set-mempolicy-invalid
Open

Skip set_mempolicy for phantom NUMA nodes#296
nileshnegi wants to merge 1 commit into
candidatefrom
users/nileshnegi/fix/set-mempolicy-invalid

Conversation

@nileshnegi
Copy link
Copy Markdown
Collaborator

@nileshnegi nileshnegi commented May 11, 2026

Motivation

Fix set_mempolicy EINVAL for memory-less NUMA nodes during topology init

Technical Details

CollectTopology() probes each NUMA node by allocating a small buffer, which calls numa_set_preferred(i) for all numa_num_configured_nodes(). If some nodes have no memory backing, set_mempolicy(MPOL_PREFERRED) returns EINVAL for them.

Guard the call with numa_get_mems_allowed() so only nodes with real memory get a preferred policy set.

Test Plan

Test Result

Submission Checklist

Copilot AI review requested due to automatic review settings May 11, 2026 00:20
@nileshnegi nileshnegi requested a review from a team as a code owner May 11, 2026 00:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents numa_run_on_node() (and the resulting set_mempolicy calls) from being invoked for “phantom” NUMA nodes that aren’t present in the process’ allowed memory-node mask, avoiding EINVAL errors on platforms that expose NUMA nodes without memory backing.

Changes:

  • Guard numa_run_on_node(exeIndex) behind a numa_get_mems_allowed() / numa_bitmask_isbitset() check in the CPU executor path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/header/TransferBench.hpp Outdated
Comment thread src/header/TransferBench.hpp Outdated
CollectTopology() probes each NUMA node by allocating a small buffer,
which calls numa_set_preferred(i) for all numa_num_configured_nodes().
If some nodes have no memory backing, set_mempolicy(MPOL_PREFERRED)
returns EINVAL for them.

Guard the call with numa_get_mems_allowed() so only nodes with real
memory get a preferred policy set.

Co-authored-by: Claude <claude@anthropic.com>
@nileshnegi nileshnegi force-pushed the users/nileshnegi/fix/set-mempolicy-invalid branch from 1366134 to 6b60e53 Compare May 11, 2026 00:33
@nileshnegi nileshnegi requested a review from Copilot May 11, 2026 01:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment on lines +1551 to +1554
// Skip memory-less NUMA nodes to avoid set_mempolicy EINVAL
if (deviceIdx < 0 || numa_bitmask_isbitset(numa_get_mems_allowed(), deviceIdx)) {
numa_set_preferred(deviceIdx);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants